<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>商户登录</title>
    <link type="text/css" rel="stylesheet" href="/plugin/bootstrap/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="/assets/css/myform.css">
    <script src="/plugin/bootstrap/js/bootstrap.min.js"></script>
    <script src="/plugin/axios.min.js"></script>
</head>
<body>
<div id="form-content">
    <div id="logo-div">
        <img src="/assets/img.login/logo.png" alt="标志" style="width: 150px">
    </div>
    <h2>登录</h2>
    <div id="errMsg" style="background-color: #db7070; color: #d000ff;text-align: center"></div>
    <div class="form-div">
        <label for="adminname" class="control-label">用户名</label>
        <input type="text" id="adminname" name="adminname" placeholder="用户名" class="form-control" style="margin-left: 60px;
               height: 29px; width: 200px;">
    </div>
    <div class="form-div">
        <label for="password" class="control-label">坤码</label>
        <input type="password" id="password" name="password" placeholder="坤码" class="form-control" style="margin-left: 60px;
               height: 29px; width: 200px;">
    </div>
    <div class="form-div form-div-spacing">
        <!--            <div>-->
        <!--                <input type="checkbox" id="remember" name="remember"> <label for="remember">记住我</label>-->
        <!--            </div>-->
        <div style="margin-left: 15px;">
            </div>
        <a href="/admin/forgetPwd" style="margin-right: 21px; ">忘记密码</a>
    </div>
    <div class="form-div">
        <input type="button" value="登      入" class="btn btn-primary btn-login" onclick="login()" style="width: 90%;
  height: 35px;margin-left: 15px;">
    </div>

</div>
<script>
    function login() {
        document.getElementById("errMsg").innerText = ''; // 先清除错误信息
        const adminname = document.getElementById("adminname").value;
        const password = document.getElementById("password").value;
        axios.post("/api/admin/login?adminname="+adminname+"&password="+password).then(res=>{
            console.log(res.data)
            const rst = res.data;
            if(rst==="ok"){
                window.location.href = "/admin/adminhome";
            }else{
                document.getElementById("errMsg").innerText = rst;
            }
        })
    }
</script>

</body>
</html>